<!--
 * @Description: react基础
 * @Author: rendc
 * @Date: 2022-06-15 08:40:01
 * @LastEditors: rendc
 * @LastEditTime: 2022-06-15 09:23:42
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>React</title>
  <!-- 加载 React。-->
  <!-- 注意: 部署时，将 "development.js" 替换为 "production.min.js"。-->
  <script src="https://unpkg.com/react@17/umd/react.development.js"></script>
  <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
  <!-- 加载我们的 React 组件。-->
  <script src="./babel.min.js"></script>
</head>

<body>
  <div>react</div>
  <div id="app">
  </div>
</body>
<script type="text/babel">
  class Toggle extends React.Component {
  constructor(props) {
    super(props);
    this.state = {isToggleOn: true};

    // 为了在回调中使用 `this`，这个绑定是必不可少的
    this.handleClick = this.handleClick.bind(this);
  }

  handleClick() {
    this.setState(state => ({
      isToggleOn: !state.isToggleOn
    }));
  }

  render() {
    return (
      <button onClick={this.handleClick}>
        {this.state.isToggleOn ? '开' : '关'}
      </button>
      );
    }
  }
  function App(props) {
    return <div><Toggle/></div>
  }
  ReactDOM.render(
    <App/>,
    document.getElementById('app')
  )

</script>

</html>